define(function () {
    'use strict';

    function ctrl($scope, $filter, InfoService,CommonService,$stateParams) {
        $scope.term = {};
        var funds = $scope.funds = new Array();
        var par = $scope.param = new Array();
        $scope.$on('$ionicView.beforeEnter', function() {
            par.theme_mark=$stateParams['id'];
            init();
        });

        $scope.doRefresh = function() {
            init();
            $scope.$broadcast("scroll.refreshComplete");
        };

        function init() {
            $scope.funds = new Array();
            //获取营地基金概况并添加事件
            queryContentBriefs();
        }

        function queryContentBriefs(){
            //0: 栏目ID 1：产品分级 2：留取条数
            var str = ($scope.term.channel).split(',');
            //查询主题信息
            InfoService.getThemeDetail(par.theme_mark).then(function(data){
                if(data&&data.relate_type){
                    //根据主题标示查询产品
                    $scope.funds=new Array();
                    InfoService.getProdByTheme(par.theme_mark,data.relate_type,data.order_rule).then(function(data){
                        if(data){
                            for(var i=0;i<data.length;i++){
                                var fund = data[i];
                                fund.prod_min_subscribe = $filter('prodMinSubscribe')(CommonService.getMinAmount(fund));
                                $scope.funds.push(fund);
                            }
                        }
                    });
                }
            });
        }
    }

    ctrl.$inject = ['$scope','$filter', 'InfoService','CommonService','$stateParams'];
    return ctrl;
});